//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_spi(SotoInternal) import SotoCore

extension SageMakerRuntime {
    // MARK: Enums

    public enum ResponseStream: AWSDecodableShape, Sendable {
        /// The stream processing failed because of an unknown error, exception or failure. Try your request again.
        case internalStreamFailure(InternalStreamFailure)
        ///  An error occurred while streaming the response body. This error can have the following error codes:  ModelInvocationTimeExceeded  The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker AI.  StreamBroken  The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.
        case modelStreamError(ModelStreamError)
        /// A wrapper for pieces of the payload that's returned in response to a streaming inference request. A streaming inference response consists of one or more payload parts.
        case payloadPart(PayloadPart)

        public init(from decoder: Decoder) throws {
            let container = try decoder.container(keyedBy: CodingKeys.self)
            guard container.allKeys.count == 1, let key = container.allKeys.first else {
                let context = DecodingError.Context(
                    codingPath: container.codingPath,
                    debugDescription: "Expected exactly one key, but got \(container.allKeys.count)"
                )
                throw DecodingError.dataCorrupted(context)
            }
            switch key {
            case .internalStreamFailure:
                let value = try container.decode(InternalStreamFailure.self, forKey: .internalStreamFailure)
                self = .internalStreamFailure(value)
            case .modelStreamError:
                let value = try container.decode(ModelStreamError.self, forKey: .modelStreamError)
                self = .modelStreamError(value)
            case .payloadPart:
                let value = try container.decode(PayloadPart.self, forKey: .payloadPart)
                self = .payloadPart(value)
            }
        }

        private enum CodingKeys: String, CodingKey {
            case internalStreamFailure = "InternalStreamFailure"
            case modelStreamError = "ModelStreamError"
            case payloadPart = "PayloadPart"
        }
    }

    // MARK: Shapes

    public struct InternalStreamFailure: AWSDecodableShape {
        public let message: String?

        @inlinable
        public init(message: String? = nil) {
            self.message = message
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
        }
    }

    public struct InvokeEndpointAsyncInput: AWSEncodableShape {
        /// The desired MIME type of the inference response from the model container.
        public let accept: String?
        /// The MIME type of the input data in the request body.
        public let contentType: String?
        /// Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.  This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
        public let customAttributes: String?
        /// The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
        public let endpointName: String
        /// The identifier for the inference request. Amazon SageMaker AI will generate an identifier for you if none is specified.
        public let inferenceId: String?
        /// The Amazon S3 URI where the inference request payload is stored.
        public let inputLocation: String?
        /// Maximum amount of time in seconds a request can be processed before it is marked as expired. The default is 15 minutes, or 900 seconds.
        public let invocationTimeoutSeconds: Int?
        /// Maximum age in seconds a request can be in the queue before it is marked as expired. The default is 6 hours, or 21,600 seconds.
        public let requestTTLSeconds: Int?

        @inlinable
        public init(accept: String? = nil, contentType: String? = nil, customAttributes: String? = nil, endpointName: String, inferenceId: String? = nil, inputLocation: String? = nil, invocationTimeoutSeconds: Int? = nil, requestTTLSeconds: Int? = nil) {
            self.accept = accept
            self.contentType = contentType
            self.customAttributes = customAttributes
            self.endpointName = endpointName
            self.inferenceId = inferenceId
            self.inputLocation = inputLocation
            self.invocationTimeoutSeconds = invocationTimeoutSeconds
            self.requestTTLSeconds = requestTTLSeconds
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodeHeader(self.accept, key: "X-Amzn-SageMaker-Accept")
            request.encodeHeader(self.contentType, key: "X-Amzn-SageMaker-Content-Type")
            request.encodeHeader(self.customAttributes, key: "X-Amzn-SageMaker-Custom-Attributes")
            request.encodePath(self.endpointName, key: "EndpointName")
            request.encodeHeader(self.inferenceId, key: "X-Amzn-SageMaker-Inference-Id")
            request.encodeHeader(self.inputLocation, key: "X-Amzn-SageMaker-InputLocation")
            request.encodeHeader(self.invocationTimeoutSeconds, key: "X-Amzn-SageMaker-InvocationTimeoutSeconds")
            request.encodeHeader(self.requestTTLSeconds, key: "X-Amzn-SageMaker-RequestTTLSeconds")
        }

        public func validate(name: String) throws {
            try self.validate(self.accept, name: "accept", parent: name, max: 1024)
            try self.validate(self.accept, name: "accept", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.contentType, name: "contentType", parent: name, max: 1024)
            try self.validate(self.contentType, name: "contentType", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.customAttributes, name: "customAttributes", parent: name, max: 1024)
            try self.validate(self.customAttributes, name: "customAttributes", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.endpointName, name: "endpointName", parent: name, max: 63)
            try self.validate(self.endpointName, name: "endpointName", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, max: 64)
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, min: 1)
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, pattern: "^\\A\\S[\\p{Print}]*\\z$")
            try self.validate(self.inputLocation, name: "inputLocation", parent: name, max: 1024)
            try self.validate(self.inputLocation, name: "inputLocation", parent: name, min: 1)
            try self.validate(self.inputLocation, name: "inputLocation", parent: name, pattern: "^(https|s3)://([^/]+)/?(.*)$")
            try self.validate(self.invocationTimeoutSeconds, name: "invocationTimeoutSeconds", parent: name, max: 3600)
            try self.validate(self.invocationTimeoutSeconds, name: "invocationTimeoutSeconds", parent: name, min: 1)
            try self.validate(self.requestTTLSeconds, name: "requestTTLSeconds", parent: name, max: 21600)
            try self.validate(self.requestTTLSeconds, name: "requestTTLSeconds", parent: name, min: 60)
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct InvokeEndpointAsyncOutput: AWSDecodableShape {
        /// The Amazon S3 URI where the inference failure response payload is stored.
        public let failureLocation: String?
        /// Identifier for an inference request. This will be the same as the InferenceId specified in the input. Amazon SageMaker AI will generate an identifier for you if you do not specify one.
        public let inferenceId: String?
        /// The Amazon S3 URI where the inference response payload is stored.
        public let outputLocation: String?

        @inlinable
        public init(failureLocation: String? = nil, inferenceId: String? = nil, outputLocation: String? = nil) {
            self.failureLocation = failureLocation
            self.inferenceId = inferenceId
            self.outputLocation = outputLocation
        }

        public init(from decoder: Decoder) throws {
            let response = decoder.userInfo[.awsResponse]! as! ResponseDecodingContainer
            let container = try decoder.container(keyedBy: CodingKeys.self)
            self.failureLocation = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-FailureLocation")
            self.inferenceId = try container.decodeIfPresent(String.self, forKey: .inferenceId)
            self.outputLocation = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-OutputLocation")
        }

        private enum CodingKeys: String, CodingKey {
            case inferenceId = "InferenceId"
        }
    }

    public struct InvokeEndpointInput: AWSEncodableShape {
        /// The desired MIME type of the inference response from the model container.
        public let accept: String?
        /// Provides input data, in the format specified in the ContentType request header. Amazon SageMaker AI passes all of the data in the body to the model.  For information about the format of the request body, see Common Data Formats-Inference.
        public let body: AWSHTTPBody?
        /// The MIME type of the input data in the request body.
        public let contentType: String?
        /// Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.  This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
        public let customAttributes: String?
        /// An optional JMESPath expression used to override the EnableExplanations parameter of the ClarifyExplainerConfig API. See the EnableExplanations section in the developer guide for more information.
        public let enableExplanations: String?
        /// The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
        public let endpointName: String
        /// If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.
        public let inferenceComponentName: String?
        /// If you provide a value, it is added to the captured data when you enable data capture on the endpoint. For information about data capture, see Capture Data.
        public let inferenceId: String?
        /// Creates a stateful session or identifies an existing one. You can do one of the following:   Create a stateful session by specifying the value NEW_SESSION.   Send your request to an existing stateful session by specifying the ID of that session.   With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the NewSessionId response parameter. For any subsequent request where you specify that session ID, SageMaker AI routes the request to the same instance that supports the session.
        public let sessionId: String?
        /// If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.
        public let targetContainerHostname: String?
        /// The model to request for inference when invoking a multi-model endpoint.
        public let targetModel: String?
        /// Specify the production variant to send the inference request to when invoking an endpoint that is running two or more variants. Note that this parameter overrides the default behavior for the endpoint, which is to distribute the invocation traffic based on the variant weights. For information about how to use variant targeting to perform a/b testing, see Test models in production
        public let targetVariant: String?

        @inlinable
        public init(accept: String? = nil, body: AWSHTTPBody? = nil, contentType: String? = nil, customAttributes: String? = nil, enableExplanations: String? = nil, endpointName: String, inferenceComponentName: String? = nil, inferenceId: String? = nil, sessionId: String? = nil, targetContainerHostname: String? = nil, targetModel: String? = nil, targetVariant: String? = nil) {
            self.accept = accept
            self.body = body
            self.contentType = contentType
            self.customAttributes = customAttributes
            self.enableExplanations = enableExplanations
            self.endpointName = endpointName
            self.inferenceComponentName = inferenceComponentName
            self.inferenceId = inferenceId
            self.sessionId = sessionId
            self.targetContainerHostname = targetContainerHostname
            self.targetModel = targetModel
            self.targetVariant = targetVariant
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.singleValueContainer()
            request.encodeHeader(self.accept, key: "Accept")
            try container.encode(self.body)
            request.encodeHeader(self.contentType, key: "Content-Type")
            request.encodeHeader(self.customAttributes, key: "X-Amzn-SageMaker-Custom-Attributes")
            request.encodeHeader(self.enableExplanations, key: "X-Amzn-SageMaker-Enable-Explanations")
            request.encodePath(self.endpointName, key: "EndpointName")
            request.encodeHeader(self.inferenceComponentName, key: "X-Amzn-SageMaker-Inference-Component")
            request.encodeHeader(self.inferenceId, key: "X-Amzn-SageMaker-Inference-Id")
            request.encodeHeader(self.sessionId, key: "X-Amzn-SageMaker-Session-Id")
            request.encodeHeader(self.targetContainerHostname, key: "X-Amzn-SageMaker-Target-Container-Hostname")
            request.encodeHeader(self.targetModel, key: "X-Amzn-SageMaker-Target-Model")
            request.encodeHeader(self.targetVariant, key: "X-Amzn-SageMaker-Target-Variant")
        }

        public func validate(name: String) throws {
            try self.validate(self.accept, name: "accept", parent: name, max: 1024)
            try self.validate(self.accept, name: "accept", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.body, name: "body", parent: name, max: 6291456)
            try self.validate(self.contentType, name: "contentType", parent: name, max: 1024)
            try self.validate(self.contentType, name: "contentType", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.customAttributes, name: "customAttributes", parent: name, max: 1024)
            try self.validate(self.customAttributes, name: "customAttributes", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.enableExplanations, name: "enableExplanations", parent: name, max: 64)
            try self.validate(self.enableExplanations, name: "enableExplanations", parent: name, min: 1)
            try self.validate(self.enableExplanations, name: "enableExplanations", parent: name, pattern: ".*")
            try self.validate(self.endpointName, name: "endpointName", parent: name, max: 63)
            try self.validate(self.endpointName, name: "endpointName", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.inferenceComponentName, name: "inferenceComponentName", parent: name, max: 63)
            try self.validate(self.inferenceComponentName, name: "inferenceComponentName", parent: name, pattern: "^[a-zA-Z0-9]([\\-a-zA-Z0-9]*[a-zA-Z0-9])?$")
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, max: 64)
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, min: 1)
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, pattern: "^\\A\\S[\\p{Print}]*\\z$")
            try self.validate(self.sessionId, name: "sessionId", parent: name, max: 256)
            try self.validate(self.sessionId, name: "sessionId", parent: name, pattern: "^(NEW_SESSION)$|^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.targetContainerHostname, name: "targetContainerHostname", parent: name, max: 63)
            try self.validate(self.targetContainerHostname, name: "targetContainerHostname", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.targetModel, name: "targetModel", parent: name, max: 1024)
            try self.validate(self.targetModel, name: "targetModel", parent: name, min: 1)
            try self.validate(self.targetModel, name: "targetModel", parent: name, pattern: "^\\A\\S[\\p{Print}]*\\z$")
            try self.validate(self.targetVariant, name: "targetVariant", parent: name, max: 63)
            try self.validate(self.targetVariant, name: "targetVariant", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct InvokeEndpointOutput: AWSDecodableShape {
        public static let _options: AWSShapeOptions = [.rawPayload]
        /// Includes the inference provided by the model.  For information about the format of the response body, see Common Data Formats-Inference. If the explainer is activated, the body includes the explanations provided by the model. For more information, see the Response section under Invoke the Endpoint in the Developer Guide.
        public let body: AWSHTTPBody?
        /// If you closed a stateful session with your request, the ID of that session.
        public let closedSessionId: String?
        /// The MIME type of the inference returned from the model container.
        public let contentType: String?
        /// Provides additional information in the response about the inference returned by a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to return an ID received in the CustomAttributes header of a request or other metadata that a service endpoint was programmed to produce. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1). If the customer wants the custom attribute returned, the model must set the custom attribute to be included on the way back.  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function. This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
        public let customAttributes: String?
        /// Identifies the production variant that was invoked.
        public let invokedProductionVariant: String?
        /// If you created a stateful session with your request, the ID and expiration time that the model assigns to that session.
        public let newSessionId: String?

        @inlinable
        public init(body: AWSHTTPBody? = nil, closedSessionId: String? = nil, contentType: String? = nil, customAttributes: String? = nil, invokedProductionVariant: String? = nil, newSessionId: String? = nil) {
            self.body = body
            self.closedSessionId = closedSessionId
            self.contentType = contentType
            self.customAttributes = customAttributes
            self.invokedProductionVariant = invokedProductionVariant
            self.newSessionId = newSessionId
        }

        public init(from decoder: Decoder) throws {
            let response = decoder.userInfo[.awsResponse]! as! ResponseDecodingContainer
            let container = try decoder.singleValueContainer()
            self.body = try container.decode(AWSHTTPBody.self)
            self.closedSessionId = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-Closed-Session-Id")
            self.contentType = try response.decodeHeaderIfPresent(String.self, key: "Content-Type")
            self.customAttributes = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-Custom-Attributes")
            self.invokedProductionVariant = try response.decodeHeaderIfPresent(String.self, key: "x-Amzn-Invoked-Production-Variant")
            self.newSessionId = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-New-Session-Id")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct InvokeEndpointWithResponseStreamInput: AWSEncodableShape {
        /// The desired MIME type of the inference response from the model container.
        public let accept: String?
        /// Provides input data, in the format specified in the ContentType request header. Amazon SageMaker AI passes all of the data in the body to the model.  For information about the format of the request body, see Common Data Formats-Inference.
        public let body: AWSHTTPBody?
        /// The MIME type of the input data in the request body.
        public let contentType: String?
        /// Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1).  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function.  This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
        public let customAttributes: String?
        /// The name of the endpoint that you specified when you created the endpoint using the CreateEndpoint API.
        public let endpointName: String
        /// If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke for a streaming response.
        public let inferenceComponentName: String?
        /// An identifier that you assign to your request.
        public let inferenceId: String?
        /// The ID of a stateful session to handle your request. You can't create a stateful session by using the InvokeEndpointWithResponseStream action. Instead, you can create one by using the  InvokeEndpoint action. In your request, you specify NEW_SESSION for the SessionId request parameter. The response to that request provides the session ID for the NewSessionId response parameter.
        public let sessionId: String?
        /// If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.
        public let targetContainerHostname: String?
        /// Specify the production variant to send the inference request to when invoking an endpoint that is running two or more variants. Note that this parameter overrides the default behavior for the endpoint, which is to distribute the invocation traffic based on the variant weights. For information about how to use variant targeting to perform a/b testing, see Test models in production
        public let targetVariant: String?

        @inlinable
        public init(accept: String? = nil, body: AWSHTTPBody? = nil, contentType: String? = nil, customAttributes: String? = nil, endpointName: String, inferenceComponentName: String? = nil, inferenceId: String? = nil, sessionId: String? = nil, targetContainerHostname: String? = nil, targetVariant: String? = nil) {
            self.accept = accept
            self.body = body
            self.contentType = contentType
            self.customAttributes = customAttributes
            self.endpointName = endpointName
            self.inferenceComponentName = inferenceComponentName
            self.inferenceId = inferenceId
            self.sessionId = sessionId
            self.targetContainerHostname = targetContainerHostname
            self.targetVariant = targetVariant
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.singleValueContainer()
            request.encodeHeader(self.accept, key: "X-Amzn-SageMaker-Accept")
            try container.encode(self.body)
            request.encodeHeader(self.contentType, key: "Content-Type")
            request.encodeHeader(self.customAttributes, key: "X-Amzn-SageMaker-Custom-Attributes")
            request.encodePath(self.endpointName, key: "EndpointName")
            request.encodeHeader(self.inferenceComponentName, key: "X-Amzn-SageMaker-Inference-Component")
            request.encodeHeader(self.inferenceId, key: "X-Amzn-SageMaker-Inference-Id")
            request.encodeHeader(self.sessionId, key: "X-Amzn-SageMaker-Session-Id")
            request.encodeHeader(self.targetContainerHostname, key: "X-Amzn-SageMaker-Target-Container-Hostname")
            request.encodeHeader(self.targetVariant, key: "X-Amzn-SageMaker-Target-Variant")
        }

        public func validate(name: String) throws {
            try self.validate(self.accept, name: "accept", parent: name, max: 1024)
            try self.validate(self.accept, name: "accept", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.body, name: "body", parent: name, max: 6291456)
            try self.validate(self.contentType, name: "contentType", parent: name, max: 1024)
            try self.validate(self.contentType, name: "contentType", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.customAttributes, name: "customAttributes", parent: name, max: 1024)
            try self.validate(self.customAttributes, name: "customAttributes", parent: name, pattern: "^\\p{ASCII}*$")
            try self.validate(self.endpointName, name: "endpointName", parent: name, max: 63)
            try self.validate(self.endpointName, name: "endpointName", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.inferenceComponentName, name: "inferenceComponentName", parent: name, max: 63)
            try self.validate(self.inferenceComponentName, name: "inferenceComponentName", parent: name, pattern: "^[a-zA-Z0-9]([\\-a-zA-Z0-9]*[a-zA-Z0-9])?$")
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, max: 64)
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, min: 1)
            try self.validate(self.inferenceId, name: "inferenceId", parent: name, pattern: "^\\A\\S[\\p{Print}]*\\z$")
            try self.validate(self.sessionId, name: "sessionId", parent: name, max: 256)
            try self.validate(self.sessionId, name: "sessionId", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.targetContainerHostname, name: "targetContainerHostname", parent: name, max: 63)
            try self.validate(self.targetContainerHostname, name: "targetContainerHostname", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
            try self.validate(self.targetVariant, name: "targetVariant", parent: name, max: 63)
            try self.validate(self.targetVariant, name: "targetVariant", parent: name, pattern: "^[a-zA-Z0-9](-*[a-zA-Z0-9])*$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct InvokeEndpointWithResponseStreamOutput: AWSDecodableShape {
        public static let _options: AWSShapeOptions = [.rawPayload]
        public let body: AWSEventStream<ResponseStream>
        /// The MIME type of the inference returned from the model container.
        public let contentType: String?
        /// Provides additional information in the response about the inference returned by a model hosted at an Amazon SageMaker AI endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to return an ID received in the CustomAttributes header of a request or other metadata that a service endpoint was programmed to produce. The value must consist of no more than 1024 visible US-ASCII characters as specified in Section 3.3.6. Field Value Components of the Hypertext Transfer Protocol (HTTP/1.1). If the customer wants the custom attribute returned, the model must set the custom attribute to be included on the way back.  The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with Trace ID: in your post-processing function. This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker AI Python SDK.
        public let customAttributes: String?
        /// Identifies the production variant that was invoked.
        public let invokedProductionVariant: String?

        @inlinable
        public init(body: AWSEventStream<ResponseStream>, contentType: String? = nil, customAttributes: String? = nil, invokedProductionVariant: String? = nil) {
            self.body = body
            self.contentType = contentType
            self.customAttributes = customAttributes
            self.invokedProductionVariant = invokedProductionVariant
        }

        public init(from decoder: Decoder) throws {
            let response = decoder.userInfo[.awsResponse]! as! ResponseDecodingContainer
            let container = try decoder.singleValueContainer()
            self.body = try container.decode(AWSEventStream<ResponseStream>.self)
            self.contentType = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-Content-Type")
            self.customAttributes = try response.decodeHeaderIfPresent(String.self, key: "X-Amzn-SageMaker-Custom-Attributes")
            self.invokedProductionVariant = try response.decodeHeaderIfPresent(String.self, key: "x-Amzn-Invoked-Production-Variant")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct ModelError: AWSErrorShape {
        ///  The Amazon Resource Name (ARN) of the log stream.
        public let logStreamArn: String?
        public let message: String?
        ///  Original message.
        public let originalMessage: String?
        ///  Original status code.
        public let originalStatusCode: Int?

        @inlinable
        public init(logStreamArn: String? = nil, message: String? = nil, originalMessage: String? = nil, originalStatusCode: Int? = nil) {
            self.logStreamArn = logStreamArn
            self.message = message
            self.originalMessage = originalMessage
            self.originalStatusCode = originalStatusCode
        }

        private enum CodingKeys: String, CodingKey {
            case logStreamArn = "LogStreamArn"
            case message = "Message"
            case originalMessage = "OriginalMessage"
            case originalStatusCode = "OriginalStatusCode"
        }
    }

    public struct ModelStreamError: AWSErrorShape {
        /// This error can have the following error codes:  ModelInvocationTimeExceeded  The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker AI.  StreamBroken  The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.
        public let errorCode: String?
        public let message: String?

        @inlinable
        public init(errorCode: String? = nil, message: String? = nil) {
            self.errorCode = errorCode
            self.message = message
        }

        private enum CodingKeys: String, CodingKey {
            case errorCode = "ErrorCode"
            case message = "Message"
        }
    }

    public struct PayloadPart: AWSDecodableShape {
        /// A blob that contains part of the response for your streaming inference request.
        public let bytes: AWSEventPayload

        @inlinable
        public init(bytes: AWSEventPayload) {
            self.bytes = bytes
        }

        public init(from decoder: Decoder) throws {
            let container = try decoder.singleValueContainer()
            self.bytes = try container.decode(AWSEventPayload.self)
        }

        private enum CodingKeys: CodingKey {}
    }
}

// MARK: - Errors

/// Error enum for SageMakerRuntime
public struct SageMakerRuntimeErrorType: AWSErrorType {
    enum Code: String {
        case internalDependencyException = "InternalDependencyException"
        case internalFailure = "InternalFailure"
        case internalStreamFailure = "InternalStreamFailure"
        case modelError = "ModelError"
        case modelNotReadyException = "ModelNotReadyException"
        case modelStreamError = "ModelStreamError"
        case serviceUnavailable = "ServiceUnavailable"
        case validationError = "ValidationError"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize SageMakerRuntime
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Your request caused an exception with an internal dependency. Contact customer support.
    public static var internalDependencyException: Self { .init(.internalDependencyException) }
    ///  An internal failure occurred.
    public static var internalFailure: Self { .init(.internalFailure) }
    /// The stream processing failed because of an unknown error, exception or failure. Try your request again.
    public static var internalStreamFailure: Self { .init(.internalStreamFailure) }
    ///  Model (owned by the customer in the container) returned 4xx or 5xx error code.
    public static var modelError: Self { .init(.modelError) }
    /// Either a serverless endpoint variant's resources are still being provisioned, or a multi-model endpoint is still downloading or loading the target model. Wait and try your request again.
    public static var modelNotReadyException: Self { .init(.modelNotReadyException) }
    ///  An error occurred while streaming the response body. This error can have the following error codes:  ModelInvocationTimeExceeded  The model failed to finish sending the response within the timeout period allowed by Amazon SageMaker AI.  StreamBroken  The Transmission Control Protocol (TCP) connection between the client and the model was reset or closed.
    public static var modelStreamError: Self { .init(.modelStreamError) }
    ///  The service is unavailable. Try your call again.
    public static var serviceUnavailable: Self { .init(.serviceUnavailable) }
    ///  Inspect your request and try again.
    public static var validationError: Self { .init(.validationError) }
}

extension SageMakerRuntimeErrorType: AWSServiceErrorType {
    public static let errorCodeMap: [String: AWSErrorShape.Type] = [
        "ModelError": SageMakerRuntime.ModelError.self,
        "ModelStreamError": SageMakerRuntime.ModelStreamError.self
    ]
}

extension SageMakerRuntimeErrorType: Equatable {
    public static func == (lhs: SageMakerRuntimeErrorType, rhs: SageMakerRuntimeErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension SageMakerRuntimeErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
